import pandas as pd
from pandas import DataFrame

#指定输出格式，否则会报错
import sys
import os
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf_8_sig') 

datafile = './文本/客运量_1-1.csv' 
datafile2 = './文本/货运量_1-1.csv'

data = pd.DataFrame(pd.read_csv(datafile))
data2 = pd.DataFrame(pd.read_csv(datafile2))

#客运量部分
#检查2007-2009年机场是否一致
for i in range(2):
    print(list(set((data[data['Year'] == 2007+i]['Airport name'].tolist())).difference(set((data[data['Year'] == 2008+i]['Airport name'].tolist())))))
for i in range(2):
    print(list(set((data[data['Year'] == 2008+i]['Airport name'].tolist())).difference(set((data[data['Year'] == 2007+i]['Airport name'].tolist())))))

#检查2010-2017年机场是否一致
for i in range(7):
    print(list(set((data[data['Year'] == 2010+i]['Airport name'].tolist())).difference(set((data[data['Year'] == 2011+i]['Airport name'].tolist())))))
for i in range(7):
    print(list(set((data[data['Year'] == 2011+i]['Airport name'].tolist())).difference(set((data[data['Year'] == 2010+i]['Airport name'].tolist())))))

#货运量部分
for i in range(2):
    print(list(set((data2[data2['Year'] == 2007+i]['Airport name'].tolist())).difference(set((data2[data2['Year'] == 2008+i]['Airport name'].tolist())))))
for i in range(2):
    print(list(set((data2[data2['Year'] == 2008+i]['Airport name'].tolist())).difference(set((data2[data2['Year'] == 2007+i]['Airport name'].tolist())))))

#检查2010-2017年机场是否一致
for i in range(7):
    print(list(set((data2[data2['Year'] == 2010+i]['Airport name'].tolist())).difference(set((data2[data2['Year'] == 2011+i]['Airport name'].tolist())))))
for i in range(7):
    print(list(set((data2[data2['Year'] == 2011+i]['Airport name'].tolist())).difference(set((data2[data2['Year'] == 2010+i]['Airport name'].tolist())))))

#结果为[]即为一致